package com.lovo.csc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lovo.csc.bean.TenderBean;
import com.lovo.csc.mapper.ITenderMapper;
import com.lovo.csc.service.ITenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

@Service
@Transactional
public class TenderServiceImpl implements ITenderService {
    @Autowired
    ITenderMapper tenderMapper;
    @Override
    public List<Integer> findAllYear() {
        return tenderMapper.findAllYear();
    }

    @Override
    public List<TenderBean> findTitleByYear(String time) {
        return tenderMapper.findTitleByYear(time);
    }

    @Override
    public void addTenderBean(Long idNum,  String conte) {
        TenderBean newTenderBean=new TenderBean();
        newTenderBean.setIdNum(String.valueOf(idNum));
//        newTenderBean.setTitle(title);
        newTenderBean.setContent(conte);
        newTenderBean.setDate(LocalDate.now());
        tenderMapper.insert(newTenderBean);
    }

    @Override
    public TenderBean findByIdNum(Long idNum) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("t_idNum",idNum);
        return tenderMapper.selectOne(qw);
    }
}